<div class="full_w">
    <div class="h_title"><?php echo Yii::t('AdmincpModule.admincp', 'Media'); ?></div>
    <h2>Media</h2>
    <p>Media consists of the images, video, recordings, and files that you upload and use in your blog. Media is typically uploaded and inserted into the content when writing a Post or writing a Page</p>
    
    <form method="get" id="form" enctype="multipart/form-data">
    <fieldset>
		<legend>Filter</legend>
        <div class="filter-row">
        	<label>Keyword: </label>
            <input type="text" name="keyword" value="<?php echo $args['keyword']; ?>">
        </div>
        <div class="filter-row">
        	<label>Type: </label>
            <select name="filetype">
                <option value="">All</option>
                <option <?php if($args['file_type'] == 'image'): ?> selected="selected"<?php endif; ?> value="image">Image</option>
                <option <?php if($args['file_type'] == 'video'): ?> selected="selected"<?php endif; ?> value="video">Video</option>
            </select>
        </div>
        <div class="filter-row">
            <label>Created from</label>
            <input tabindex="5" type="text" id="dfrom" name="dfrom" class="datepicker" value="<?php echo $args['created_from']; ?>" />
            <span style="float:left; width:22px; text-align:center; margin-top:6px;">To</span> 
            <input tabindex="6" type="text" id="dto" name="dto" class="datepicker" value="<?php echo $args['created_to']; ?>" />
        </div>     
        <div class="filter-row">
            <label>Label</label>
            <select name="status" id="status">
            	<option value="">All</option>               
            </select>
        </div>  
        <div style="clear:both; text-align:center">
            <input type="submit" value="Search" /> 
            <input type="reset" name="Clear">
        </div>
    </fieldset>			
    </form>
    <script type="text/javascript">
	$(function() {
		$("#dfrom").datepicker({
			dateFormat:'dd-mm-yy',
			maxDate: '0',
			changeMonth: true,
			changeYear: true,
			onClose: function( selectedDate ) {
				if(selectedDate != ''){
					$("#dto").datepicker( "option", "minDate", selectedDate );
				}
			}
		});
		$("#dto").datepicker({
			dateFormat:'dd-mm-yy',
			maxDate: '0',
			changeMonth: true,
			changeYear: true,
			onClose: function( selectedDate ) {
				if(selectedDate != ''){
					$("#dfrom").datepicker( "option", "maxDate", selectedDate );
				}
			}
		});
	});
	</script>
    <div class="entry">
        <div class="sep"></div>
    </div>
    <table>
        <thead>
            <tr>
            	<th scope="col" class="chb"><input type="checkbox" onclick="selectAll(this);"></th>
                <th scope="col"><?php  echo Yii::t('AdmincpModule.admincp', 'File');?></th>
                <th scope="col"><?php  echo Yii::t('AdmincpModule.admincp', 'Title');?></th>
                <th scope="col" width="60px"><?php  echo Yii::t('AdmincpModule.admincp', 'Date');?></th>
                <th scope="col"><?php  echo Yii::t('AdmincpModule.admincp', 'Author');?></th>
            </tr>
        </thead>
            
        <tbody>
        
        <?php if(!empty($arrMedia)):?>
			<?php foreach($arrMedia as $i=>$R):?>
            <tr>
                <td class="align-center"><input type="checkbox"></td>
				<td>
					<?php if(in_array($R['media_file_extension'], array('jpg', 'jpeg', 'png', 'gif', 'bmp'))): ?>
                    <a class="fancybox" href="<?php echo UPLOADS_URL.'/'.$R['media_file']; ?>">
						<img class="lazy" src="img/grey.gif" data-original="<?php echo UPLOADS_URL.'/'.$R['media_file']; ?>" style="max-width:100px; max-height:100px;">
					</a>
					<?php elseif(in_array($R['media_file_extension'], array('swf'))): ?>
					<object width="100" height="100" data="<?php echo UPLOADS_URL.'/'.$R['media_file']; ?>"></object> 
					<?php else: ?>
					<img class="lazy" src="img/grey.gif" data-original="img/icons/file.png" />
					<?php endif; ?>
				</td>
                <td>
					<label>File name:</label> <strong><a><?php echo $R['media_title']; ?></a></strong><br />
                    <label>File URL:</label> <?php echo UPLOADS_URL.'/'.$R['media_file']; ?><br />
                    <label>File size:</label> <?php echo $R['media_file_size']; ?> KB<br />
                	 <p style="margin:0; padding: 2px 0 0;">
                        <a href="<?php echo LINK_ADMINCP_MEDIA.'/form/?id='.$R['media_id']; ?>"  title="Edit">Edit</a> | 
                        <a href="<?php echo LINK_ADMINCP_MEDIA.'/delete/?id='.$R['media_id']; ?>" title="Delete">Delete forever</a> 
                    </p>
                </td>
				<td><?php echo $R['media_created_date']; ?></td>
                <td><?php echo $R['media_creator_id']; ?></td>
            </tr>
            <?php endforeach; ?>
		<?php else: ?>
            <tr>
                <td colspan="7">No data found!</td>
            </tr>
        <?php endif; ?>
        </tbody>
    </table>
    <div class="entry">
        <?php $this->widget('Pagination', array(
			'pages' => $objPages,
		)) ?>
        <div class="sep"></div>		
        <a class="button add" href="<?php echo LINK_ADMINCP_MEDIA.'/form'; ?>"><?php echo Yii::t('AdmincpModule.admincp', 'Add New'); ?></a> 
    </div>
</div>
<script type="text/javascript" src="../libs/jquery/lazyload/jquery.lazyload.min.js"></script>
<script type="text/javascript">
$(function(){
	$("img.lazy").lazyload({
		failure_limit : 200,
		skip_invisible : false,
		effect : "fadeIn"
	}).removeClass("lazy");
	$(".fancybox").fancybox({
		openEffect	: 'none',
		closeEffect	: 'none'
	});
});
</script>